package com.example.chap2;

import android.content.Intent;
import android.graphics.Color;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
//      将10dp的尺寸转换为对应的px
        int dip_10=Utils.dip2px(this,10L);
        TextView tv_padding=findViewById(R.id.tv_padding);
//        设置该文本视图的内部文字与控件四周的间隔大小
        tv_padding.setPadding(dip_10,dip_10,dip_10,dip_10);

        tv_padding.setBackgroundColor(getResources().getColor(R.color.teal_200));

        String tmp;
        tmp="当前屏幕宽度是:";
        tmp+=Utils.getScreenWidth(this);
        tmp+="\n";
        tmp+="当前屏幕高度是:";
        tmp+=Utils.getScreenHeight(this);
        tmp+="\n";
        tmp+="像素密度是:";
        tmp+=Utils.getScreenDensity(this);
        tmp+="\n";
        tv_padding.setText(tmp);
    }
    public void changeLayout1(View view){
        Intent i = new Intent(MainActivity.this , LinearLayout1.class);
        startActivity(i);
    }
    public void changeLayout2(View view){
        Intent i = new Intent(MainActivity.this , LinearLayout2.class);
        startActivity(i);
    }
    public void changeLayout3(View view){
        Intent i = new Intent(MainActivity.this , ScrollView.class);
        startActivity(i);
    }
    public void simple_ctl_1(View view){
        Intent i = new Intent(MainActivity.this , SimpleCtl1.class);
        startActivity(i);
    }
    public void simple_ctl_2(View view){
        Intent i = new Intent(MainActivity.this , SimpleCtl2.class);
        startActivity(i);
    }
}